package com.suxin.oci.mapper.oci;

import com.suxin.oci.domain.internet.V4MisEn;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @author Tang
 * @classname V4MisEnMapper
 * @description [  ]
 * @date 2021/4/26 15:07
 */
public interface V4MisEnHistoryMapper {

    @Insert(value = {
            "insert into v4misen_history_2021 (id, tid, tname,",
            "ttype, dy, dm, dd,",
            "dh, dn, `temp`, press,flowm,",
            "flowsumm, flowsumq, presSma,",
            "flowq,create_time)",
            "values (null , #{tid}, #{tName},",
            "#{tType}, #{dy}, #{dm}, #{dd},",
            "#{dh}, #{dn}, #{temp}, #{press},#{flowM}",
            "#{flowSumm}, #{flowSumQ}, #{presSma},",
            "#{flowQ},now())"
    })
    int insert(V4MisEn record);

    @Insert(value = {
            "<script>",
            "INSERT INTO v4misen_history_2021 (",
            "id,tid,tname,ttype,dy,dm,dd,",
            "dh,dn,temp,press,flowm,flowsumm,flowsumq,presSma,flowq,create_time )VALUES",
            "<foreach collection=\"list\" item=\"element\" index=\"index\" separator=\",\">",
            "( null, #{element.tid}, #{element.tName},",
            "#{element.tType}, #{element.dy}, #{element.dm},",
            "#{element.dd}, #{element.dh}, #{element.dn},",
            "#{element.temp}, #{element.press},#{element.flowM}, #{element.flowSumm},",
            "#{element.flowSumQ}, #{element.presSma}, #{element.flowQ},",
            "now())",
            "</foreach>",
            "</script>",
    })
    int insertList(@Param("list") List<V4MisEn> list);


    /**
     * 查询指定时间的历史数据
     * @param date
     * @return
     */
    @Results(id = "V4MisEn",value = {
            @Result(id = true,column = "tid",property = "id"),
            @Result(column = "tid",property = "tid"),
            @Result(column = "tName",property = "tName"),
            @Result(column = "tType",property = "tType"),
            @Result(column = "dy",property = "dy"),
            @Result(column = "dm",property = "dm"),
            @Result(column = "dd",property = "dd"),
            @Result(column = "dh",property = "dh"),
            @Result(column = "dn",property = "dn"),
            @Result(column = "temp",property = "temp"),
            @Result(column = "press",property = "press"),
            @Result(column = "flowm",property = "flowM"),
            @Result(column = "flowsumm",property = "flowSumm"),
            @Result(column = "flowsumq",property = "flowSumQ"),
            @Result(column = "pressma",property = "presSma"),
            @Result(column = "flowq",property = "flowQ"),
    })
    @Select(value = "select * from v4misen_history_2021 where create_time = #{date} ")
    List<V4MisEn> selectByDate(@Param("date") String date);
}